﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityLayer;
using DataLayer.EF;
namespace DataLayer.CLASES_DAO
{
    public class clsTB_SupervisorDAO
    {

        private BD_TRASNFINTEREntities ContextoDeObjs = new BD_TRASNFINTEREntities();
        public bool Insertar(TB_Supervisor Obj)
        {
            try
            {
                ContextoDeObjs.AddObject("TB_Supervisor", Obj);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool Modificar(TB_Supervisor obj)
        {
            try
            {
                ContextoDeObjs.AttachTo("TB_Supervisor", obj);
                ContextoDeObjs.ObjectStateManager.ChangeObjectState(obj, System.Data.EntityState.Modified);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;

            }
            return true;
        }
        public bool Eliminar(TB_Supervisor obj)
        {
            try
            {
                ContextoDeObjs.AttachTo("TB_Supervisor", obj);
                ContextoDeObjs.DeleteObject(obj);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public List<TB_Supervisor> listar()
        {

            List<TB_Supervisor> lista = new List<TB_Supervisor>();
            try
            {
                var q = from c in ContextoDeObjs.TB_Supervisor
                        select c;
                lista = q.ToList();

            }
            catch (Exception)
            {
            }
            return lista;
        }
        public List<TB_Supervisor> listarxID(string id)
        {

            List<TB_Supervisor> lista = new List<TB_Supervisor>();
            try
            {
                var q = from c in ContextoDeObjs.TB_Supervisor
                        where c.matriculaSupervisor==id
                        select c;
                lista = q.ToList();

            }
            catch (Exception)
            {
            }
            return lista;
        }
        
    }
}
